<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>欢迎页面-L-admin1.0</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <link rel="stylesheet" href="/cms/css/font.css">
  <link rel="stylesheet" href="/cms/css/xadmin.css">
  <link rel="stylesheet" href="/cms/layui/css/layui.css">
  <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
  <!--[if lt IE 9]>
  <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  <![endif]-->
</head>

<body class="form-wrap">

<div class="layui-fluid">
  <div class="layui-row layui-col-space15">

    <div class="layui-col-md12">
      <div class="layui-card">
        <div class="layui-card-header">医生信息</div>
        <div class="layui-card-body">
          <form class="layui-form" action="" lay-filter="component-form-element">
            <input type="hidden" id="id" name="id" th:value="${doctor.id}">
            <div class="layui-row layui-col-space10 layui-form-item">
              <div class="layui-col-lg6">
                <label class="layui-form-label">医生名称：</label>
                <div class="layui-input-block">
                  <input type="text" name="doctorName" th:value="${doctor.doctorName}" lay-verify="required"
                         placeholder="" autocomplete="off"
                         class="layui-input">
                </div>
              </div>
              <div class="layui-col-lg6">
                <label class="layui-form-label">医生职位：</label>
                <div class="layui-input-block">
                  <input type="text" name="position" th:value="${doctor.position}" lay-verify="required" placeholder=""
                         autocomplete="off"
                         class="layui-input">
                </div>
              </div>
            </div>


            <div class="layui-upload">
              <button type="button" class="layui-btn" id="test1">医生图片</button>
              <div class="layui-upload-list">
                <img name="headImg" class="layui-upload-img" th:src="${doctor.headImg}"  style="width: 360px;height: 360px;" id="demo1">
                <input type="hidden" name="headImg" th:value="${doctor.headImg}"   id="headImg">
                <p id="demoText"></p>
              </div>
            </div>



            <div class="layui-col-lg6">
              <label class="layui-form-label">所属科室：</label>
              <div class="layui-input-block">
                <select name="keshiId">
                  <option th:switch="${doctor.keshiId == keshi.id}" th:each="keshi:${keshis}" th:case="true"
                          th:selected="selected" th:value="${keshi.id}" th:text="${keshi.name}"></option>
                  <option th:switch="${doctor.keshiId == keshi.id}" th:each="keshi:${keshis}" th:case="false"
                          th:value="${keshi.id}" th:text="${keshi.name}"></option>
                </select>

              </div>
            </div>


            <div class="layui-form-item">
              <label class="layui-form-label">医生状态：</label>

              <div class="layui-input-block" th:switch="${doctor.status} == 1">
                <div th:case="true">
                  <input type="radio" name="status" checked="checked" value="1" title="在职">
                  <input type="radio" name="status" value="2" title="离职">
                </div>

                <div th:case="false">
                  <input type="radio" name="status" value="1" title="在职">
                  <input type="radio" name="status" checked="checked" value="2" title="离职">
                </div>
              </div>
            </div>


            <div class="layui-form-item">
              <label class="layui-form-label">出诊</label>
              <div class="layui-input-block">
                <div th:switch="${chuzhen.a == '1'}" style="float: left">
                  <input type="checkbox" th:case="true" name="a" title="周一上午" checked>
                  <input type="checkbox" th:case="false" name="a" title="周一上午">
                </div>

                <div th:switch="${chuzhen.b == '1'}" style="float: left">
                  <input type="checkbox" th:case="true"  name="b" title="周一下午" checked="">
                  <input type="checkbox" th:case="false" name="b"  title="周一下午">
                </div>
                <div th:switch="${chuzhen.c == '1'}" style="float: left">
                  <input type="checkbox" th:case="true"  name="c"  title="周二上午" checked="">
                  <input type="checkbox" th:case="false" name="c"   title="周二上午">
                </div>


                <div th:switch="${chuzhen.d eq'1'}" style="float: left">
                  <input type="checkbox" name="d"  th:case="true" title="周二下午" checked>
                  <input type="checkbox" name="d"  th:case="false" title="周二下午">
                </div>

                <div th:switch="${chuzhen.e eq'1'}" style="float: left">
                  <input type="checkbox" name="e"  th:case="true" title="周三上午" checked>
                  <input type="checkbox" name="e"  th:case="false" title="周三上午">
                </div>
                <div th:switch="${chuzhen.f eq '1'}" style="float: left">
                  <input type="checkbox" name="f"  th:case="true" title="周三下午" checked>
                  <input type="checkbox" name="f"  th:case="false" title="周三下午">
                </div>
                <div th:switch="${chuzhen.g eq '1'}" style="float: left">
                  <input type="checkbox" name="g"  th:case="true" title="周四上午" checked>
                  <input type="checkbox" name="g"  th:case="false" title="周四上午">
                </div>
                <div th:switch="${chuzhen.h eq '1'}" style="float: left">
                  <input type="checkbox" name="h"  th:case="true" title="周四下午" checked>
                  <input type="checkbox" name="h"  th:case="false" title="周四下午">
                </div>
                <div th:switch="${chuzhen.i eq '1'}" style="float: left">
                  <input type="checkbox" name="i"  th:case="true" title="周五上午" checked>
                  <input type="checkbox" name="i"  th:case="false" title="周五上午">
                </div>
                <div th:switch="${chuzhen.j eq '1'}" style="float: left">
                  <input type="checkbox" name="j"  th:case="true" title="周五下午" checked>
                  <input type="checkbox" name="j"  th:case="false" title="周五下午">
                </div>
                <div th:switch="${chuzhen.k eq '1'}" style="float: left">
                  <input type="checkbox" name="k"  th:case="true" title="周六上午" checked>
                  <input type="checkbox" name="k"  th:case="false" title="周六上午">
                </div>

                <div th:switch="${chuzhen.l eq '1'}" style="float: left">
                  <input type="checkbox" name="l"  th:case="true" title="周六下午" checked>
                  <input type="checkbox" name="l"  th:case="false" title="周六下午">
                </div>
                <div th:switch="${chuzhen.m eq '1'}" style="float: left">
                  <input type="checkbox" name="m"  th:case="true" title="周日上午" checked>
                  <input type="checkbox" name="m"  th:case="false" title="周日上午">
                </div>
                <div th:switch="${chuzhen.n eq '1'}" style="float: left">
                  <input type="checkbox" name="n"  th:case="true" title="周日下午" checked>
                  <input type="checkbox" name="n"  th:case="false" title="周日下午">
                </div>



              </div>
            </div>


            <div class="layui-form-item">
              <label class="layui-form-label">医生简介</label>
              <div class="layui-input-block">
                <textarea id="lay_edit" lay-verify="content" name="jianjie" th:text="${doctor.jianjie}"></textarea>

              </div>
            </div>


            <div class="layui-form-item">
              <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="formSubmit">立即提交</button>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>

<script type="text/javascript" src="/js/jquery.min.js"></script>
<script src="/cms/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="/cms/js/xadmin.js"></script>
<script>
  layui.use(['layedit','upload', 'form'], function () {
    var form = layui.form;
    var layedit = layui.layedit;
    var upload = layui.upload;
    layedit.set({	//设置图片接口
      uploadImage: {
        url: '/file/uploads', //接口url
        type: 'post'
      }
    });
    //创建一个编辑器
    var index = layedit.build('lay_edit', {
      height: 350
    });
    //提交时把值同步到文本域中
    form.verify({
      //content富文本域中的lay-verify值
      content: function (value) {
        return layedit.sync(index);
      }
    });


    //普通图片上传
    var uploadInst = upload.render({
      elem: '#test1'
      ,url: '/file/uploads' //改成您自己的上传接口
      ,before: function(obj){
        //预读本地文件示例，不支持ie8
        obj.preview(function(index, file, result){
          $('#demo1').attr('src', result); //图片链接（base64）
        });
      }
      ,done: function(res){
        console.log(res)
        //如果上传失败
        if(res.code !=0){
          return layer.msg('上传失败');
        }
        //上传成功
        $("#headImg").val(res.data.src);
      }
      ,error: function(){
        //演示失败状态，并实现重传
        var demoText = $('#demoText');
        demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
        demoText.find('.demo-reload').on('click', function(){
          uploadInst.upload();
        });
      }
    });


    form.on("submit(formSubmit)", function (data) {

      $.post("/cms/doctor/save", data.field, function (result) {
        layer.msg(result.msg);
      });
      return false;
    })



  });
</script>
</body>


</html>